package com.cslg.ac.demo.dao.pet;

import com.cslg.ac.demo.dao.pet.po.PetFosterPO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface PetFosterDAO {

    String TABLE_NAME = "e_pet_foster";
    String SELECT_FIELD = "id,album_count albumCount";

    @Insert({"insert into",TABLE_NAME,"set id = #{id}"})
    void insert(@Param("id")int id);

    @Delete({"delete from ",TABLE_NAME,"where id = #{id}"})
    void delete(@Param("id")int id);

    @Update({"update ",TABLE_NAME,"set album_count = #{albumCount} where id = #{id}"})
    void updateAlbum(PetFosterPO petFosterPO);

    @Select({"select", SELECT_FIELD,"from",TABLE_NAME,"where id = #{id}"})
    PetFosterPO selectById(@Param("id")int id);

    @Select({"select id from ", TABLE_NAME, "order by id desc limit #{offset}, #{num} " })
    List<Integer> sortByTime(@Param("offset")int offset, @Param("num")int num);
}
